const app = getApp()
Page({
  onLoad() {
    app.token && this.getUserProfile()
  },

  async getUserProfile() {
    //调用用户信息接口
    const {
      code,
      data: {
        avatar,
        nickName
      }
    } = await wx.http.get('/userInfo')
    //检测是否调用成功
    if (code !== 10000) return wx.utils.toast()
    //渲染数据
    this.setData({
      avatar: wx.utils.toHttps(avatar),
      nickName
    })
  },

  goLogin() {
    wx.navigateTo({
      url: '/pages/login/index',
    })
  },
})